/**
 * @project_name thread
 * @package_name com.gxwz.thread
 * @file_name CreateThreadWays.java
 */
package com.gxwz.thread;

/**
 * 线程的创建方式；一共两种，推荐使用第二种方式，
 * 
 * @author chendequan
 * @email 1527254027@qq.com
 * @datetime 2013-9-5 上午01:22:06
 * 
 */
public class CreateThreadWays {

	/**
	 * @datetime 2013-9-5 上午01:22:06
	 * @param args
	 */
	public static void main(String[] args) {
//		创建线程方式1； 继承Thread类
		new Thread(){
			@Override
			public void run() {
				System.out.println("first way to " +
						"create thread, the thread is " + Thread.currentThread().getName());
			};
		}.start();
		
//		创建线程方式2； 实现Runnable接口;必须要实现run方法
		new Thread(new Runnable() {
			/* (non-Javadoc)
			 * @see java.lang.Runnable#run()
			 */
			@Override
			public void run() {
				System.out.println("-- second way to " +
						"create thread, the thread is " + Thread.currentThread().getName());
			}
		}).start();
	}
}
